//
//  ZJRouteTool.m
//  iosFramework
//
//  Created by Farben on 2020/8/6.
//  Copyright © 2020 Farben. All rights reserved.
//

#import "ZJRouteTool.h"
#import "UIViewController+CurrentVC.h"

@interface ZJRouteTool()

@end

@implementation ZJRouteTool

static ZJRouteTool *_sharedSingleton = nil;
+ (instancetype)Share{
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        //不能再使用alloc方法
        //因为已经重写了allocWithZone方法，所以这里要调用父类的分配空间的方法
        _sharedSingleton = [[super allocWithZone:NULL] init];
    });
    return _sharedSingleton;
}

-(BaseViewController*)getViewControllerWithName:(NSString*)ViewControllerName{
    BaseViewController *vc = (BaseViewController*)[[NSClassFromString(ViewControllerName) alloc] init];
    return vc;
}


#pragma mark -"无参数poush"

-(void)pushViewController:(BaseViewController*)pushVC{
    
    NSString *VCName = NSStringFromClass([pushVC class]);
    NSLog(@"*************************************************************");
    NSLog(@"========  无参数 push -- %@  ============",VCName);
    NSLog(@"*************************************************************");
    [[UIViewController getCurrentViewController].navigationController pushViewController:pushVC animated:YES];
}

#pragma mark -"带参数poush"

-(void)pushViewController:(BaseViewController*)pushVC withPatameter:(NSDictionary*)parameters{
    
    pushVC.parameters = [parameters copy];
    
    NSString *VCName = NSStringFromClass([pushVC class]);
    
    NSLog(@"*************************************************************");
    NSLog(@"========  带参数 push -- %@ -- parameters:[%@]  ============",VCName,parameters);
    NSLog(@"*************************************************************");
    [[UIViewController getCurrentViewController].navigationController pushViewController:pushVC animated:YES];
}



@end
